
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using EngineOfEvermore.Scene;
using EngineOfEvermore.Editor.Common.Command;

namespace EngineOfEvermore.Editor.SceneEditor
{
	public class Model
	{
		public event Action<Model> SelectionChanged;
		public event Action<Model> CommandStackChanged;
		
		public SceneGraph Scene;
		public List<SceneObject> ActiveSelection;
		public CommandStack CommandStack;
	}
	
	public class SceneWindowView
	{
		private SceneWindowController _controller;
		private Control _control;
		
		public SceneWindowView( SceneWindowController controller, Control control )
		{
			_controller = controller;
			_control = control;
			
			_control.MouseDown += HandleMouseDown;
		}

		void HandleMouseDown(object sender, MouseEventArgs e)
		{
			_controller.HandleMouseDown( e );
		}
		
		
	}
	
	public interface IInputHandler
	{
		bool HandleMouseEvent( System.Windows.Forms.MouseEventArgs e, Model activeModel );
        bool HandleKeyboardEvent( System.Windows.Forms.KeyEventArgs e, Model activeModel );
	}
	
	public class GlobalInputHandler
	{
		public bool HandleMouseEvent( System.Windows.Forms.MouseEventArgs e, Model activeModel )
		{
			throw new NotImplementedException();
		}
		
        public bool HandleKeyboardEvent( System.Windows.Forms.KeyEventArgs e, Model activeModel ) 
		{
			throw new NotImplementedException();
		}
		
		public void RegisterInputHandler( IInputHandler handler ) {}
		public void UnregisterInputHandler( IInputHandler handler ) {}
	}
		
	
	public class ControllerContext
	{
		public Controller.ISceneTool ActiveSceneTool
		{
			get;
			set;
		}
		
		
		public GlobalInputHandler GlobalInputHandler
		{
            get { return null; }
		}
	}
	
	public class SceneWindowController
	{
		ControllerContext _context;
		Model _model;
		
		public SceneWindowController()
		{
		}
		
		public void HandleMouseDown( MouseEventArgs e )
		{
			bool handled = _context.ActiveSceneTool.HandleMouseEvent( e, _model );
			
			if ( !handled )
			{
				_context.GlobalInputHandler.HandleMouseEvent( e, _model );
			}
		}
		
	}
	
	public class PropertyEditorController
	{
		
		
	}
	
	public class PropertyEditorView
	{
		
	}
	
	
}
